package cn.edu.bcu.ls.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.edu.bcu.ls.entity.Section;
import cn.edu.bcu.ls.entity.SectionParams;
import cn.edu.bcu.ls.entity.User;
import cn.edu.bcu.ls.serviceImpl.SectionService;
import io.swagger.annotations.ApiOperation;

@RestController
public class SectionController {
	@Autowired
	private SectionService sectionService;

	@ApiOperation(value = "上传章节内容，传入你想要的传的值就行")
	@PostMapping(value="Section")
	public boolean insertUser(Section section) {
		if (sectionService.insertSelective(section) >0) {
			return true;
		}else {
			return false;
		}
	}
	
	
	 @ApiOperation(value="修改章节内容，传入id和想修改的值")
	 @PutMapping(value="Section")
	 public boolean updateSection(Section section) {
		 if (sectionService.updateByPrimaryKeySelective(section) >0) {
				return true;
			}else {
				return false;
			}
	 }

	 @ApiOperation(value = "根据sId，cId返回该章节的课程所有信息")
		@GetMapping(value="Section")
		public List selectByPrimaryKey(SectionParams sectionParams) {
			List<Section> sctions = sectionService.selectBysIdcId(sectionParams);
			System.out.print(sctions);
			return sctions;
		}

	 @ApiOperation(value = "根据cId返回该章节的课程所有信息")
		@GetMapping(value="SectionFindCourse/{c_id}")
		public List selectByCid(@PathVariable("c_id") Integer c_id) {
			List<Section> sctions = sectionService.selectBycId(c_id);
			System.out.print(sctions);
			return sctions;
		}

}
